Skip to content

fix: MMPay fiat payment fixes #8987

Open
OGPoyraz wants to merge 34 commits into
mainfrom
ogp/fiat-money-account-deposit-fix
Open

fix: MMPay fiat payment fixes #8987
OGPoyraz wants to merge 34 commits into
mainfrom
ogp/fiat-money-account-deposit-fix

Conversation

@OGPoyraz
Copy link
Copy Markdown
Member

@OGPoyraz OGPoyraz commented Jun 3, 2026

Explanation

Fiat payments for moneyAccountDeposit transactions fail with multiple sequential errors after the on-ramp order settles:

  1. isMaxAmount: true in the fiat re-quote — after Transak settles, submitRelayAfterFiatCompletion re-quotes with isMaxAmount: true, isPostQuote: false. This calls processTransactions, which throws "Max amount quotes do not support included transactions" because moneyAccountDeposit has nested txs (approve + deposit) that require delegation.

  2. validateRelaySlippage compares wrong amounts — it compares currencyOut.amount from two relay quotes made with different source amounts (theoretical $5 quoting phase vs actual ~$4.95 post-Transak settlement). This produces ~25% apparent "slippage" that is not real slippage — it is just a smaller input producing a smaller output.

  3. Nested calldata has zero amounts — the fiat path in handleDone only sets amountFiat and never calls updateTokenAmount(), so requiredAssets.amount stays 0x0 and the nested approve + deposit calldata encodes zero amounts.

  4. Wrong wallet address in fiat flowfiat-quotes.ts and fiat-submit.ts used transaction.txParams.from as the wallet address. For moneyAccountDeposit, txParams.from is the money account address on the target chain (Monad), not the user's EOA. This caused Ramps/Transak to receive the wrong deposit address, resolveSourceAmountRaw to look for on-chain ETH at the wrong address, and all relay quotes to use the wrong from/user address — resulting in TRANSFER_FROM_FAILED reverts.

  5. Fiat total calculation using wrong amountcalculateTotals derived the payment amount from token amounts or targetAmount, which is incorrect for fiat flows where the user enters a specific fiat amount.

Changes

fiat-quotes.ts — uses accountOverride when available for walletAddress, matching the existing pattern in quotes.ts. This ensures Ramps/Transak receives the user's actual EOA address, not the money account address.

fiat-submit.ts — two wallet address fixes plus three-phase relay flow:

  • submitFiatQuotes: uses accountOverride ?? txParams.from for order polling wallet address
  • submitRelayAfterFiatCompletion: uses baseRequest.from (already accountOverride-aware from the quote) for on-chain amount lookup
  • Phase 1: Discovery relay quote (isPostQuote: true, EXACT_INPUT) with the settled source amount to learn currencyOut.minimumAmount
  • Phase 2: Calls getAmountData via messenger to delegate calldata re-encoding to the client, then patches nested tx data + requiredAssets[0].amount
  • Phase 3: Real relay quote (isPostQuote: false, EXACT_OUTPUT) with delegation

relay-submit.ts — reverts the isExecute balance skip (no longer needed with correct wallet address). The balance check now correctly validates the user's EOA balance.

validateRelaySlippagevalidateRelayRateDrift — compares USD exchange rate ratios (output_usd / input_usd) between original and discovery quotes instead of absolute amounts, normalising for different source amounts.

TransactionPayController — adds optional getAmountData callback on the constructor, exposed via messenger as TransactionPayController:getAmountData. Keeps ABI knowledge on the client side.

totals.ts — adds fiatPaymentAmount parameter to calculateTotals. When a fiat strategy quote is present, uses the user-entered fiat payment amount directly instead of deriving it from token amounts or relay targetAmount. Falls back to '0' if fiat amount is unavailable.

quotes.ts — passes fiatPayment.amountFiat from the transaction pay state into calculateTotals as fiatPaymentAmount.

relay-quotes.ts (recipient routing fix) — adds skipProcessTransactions to QuoteRequest type. Defaults to isPostQuote when not set. The simple fiat path (fiat-submit-simple.ts) sets skipProcessTransactions: false to force processTransactions to run and extract the transfer(to, amount) recipient from calldata — fixing Predict/Perps deposits where Relay sent swapped tokens to the user's EOA instead of the target contract.

relay-quotes.ts (7702 batch gas estimation) — for post-quote flows, includes the original transaction in batch gas estimation alongside relay params. Previously, a single relay step was estimated alone, got is7702: false, and the batch fell back to separate type-0x2 transactions — breaking zero-balance fiat-funded accounts that need all native tokens for the swap.

relay-quotes.ts (native gas subtraction) — extends the phase-2 gas subtraction to trigger when the source token is the native gas token (e.g. POL on Polygon), not only when isSourceGasFeeToken is true. For zero-balance accounts where the source IS the native token, gas must be reserved from the source amount to avoid insufficient funds for gas * price + value.

relay-submit.ts (gas price alignment) — the prepended original transaction in post-quote batch submissions now carries the relay step's maxFeePerGas and maxPriorityFeePerGas. This ensures the top-level 7702 batch uses the same gas price as the relay quote, matching the gas cost computed during the phase-2 gas subtraction.

eip7702.ts (transaction-controller)generateEIP7702BatchTransaction now sums native values from all nested calls and sets the result as the top-level transaction value. Previously the top-level value was always 0x0, causing 7702 batches with native value transfers (e.g. POL swap) to revert because the delegation contract had no native tokens to forward.

fiat-quotes.ts (accountOverride fix) — uses accountOverride ?? txParams.from for the wallet address, matching the pattern in fiat-submit.ts. For moneyAccountDeposit, txParams.from is the money account on the target chain, not the user's EOA. This caused relay quotes to use the wrong from/user address, and Relay Execute to pull funds from an empty account.

relay-submit.ts (isExecute balance skip) — skips the source balance validation when the Relay Execute flow is active (isExecute: true). In Execute flows, Relay's relayer handles the source-side transaction — the user's account doesn't need to hold the source tokens at submit time.

fiat-submit-with-calldata.ts (rate drift moved) — moves the validateRelayRateDrift check from after the discovery quote (phase 1) to after the final EXACT_OUTPUT quote (phase 3). The discovery quote uses a reduced source amount (after fee reserve), causing an unfair rate comparison with the original quote on cross-chain routes where relay fees are a large percentage. The final quote uses the full source amount, making the comparison accurate.

feature-flags.ts (fee reserve default) — bumps DEFAULT_FEE_RESERVE_MULTIPLIER from 1 to 1.2. On cross-chain routes with high relay fees (ETH→Monad), a 1x reserve was too tight — relay fees could increase slightly between the discovery and final quotes, causing the final EXACT_OUTPUT to overshoot the settled balance. 1.2x provides 20% headroom.

Feature Flags (LaunchDarkly)

This PR reads optional properties from two feature flags. No new LaunchDarkly flags need to be created — these are properties on existing flag objects.

confirmations_pay_fiat

Property Type Default Description
feeReserveMultiplier number 1.2 Multiplier applied to the original relay fee when reserving source tokens for the discovery quote. Increase (e.g. 1.5) if EXACT_OUTPUT quotes consistently exceed the settled balance after settlement on cross-chain routes.
maxRateDriftPercent number 10 Maximum allowed relay exchange rate drift (%) between the original fee quote and the post-settlement discovery quote. Increase if legitimate market moves cause false rejections.

confirmations_pay_post_quote

Property Type Default Description
gasBuffer number 1.1 Multiplier applied to the estimated gas cost when reserving native tokens for gas in post-quote flows. Accounts for minor gas limit variance between quote-time and submission-time batch estimation. Increase if zero-balance fiat deposits fail with insufficient funds.

No action required for launch — all properties default to safe values when absent. They exist as remote safety valves to tune post-settlement behavior without a code release.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

High Risk
Changes payment settlement, relay quoting/submission, and EIP-7702 batch value handling across fiat and zero-balance paths; regressions could block deposits or mis-route funds.

Overview
Fixes MMPay fiat flows after on-ramp settlement and tightens relay / EIP-7702 behavior for zero-balance and nested-tx deposits.

Fiat submit & quoting — After the ramp order completes, post-settlement relay is split: simple deposits (e.g. Perps/Predict) use one EXACT_INPUT post-quote with skipProcessTransactions: false so recipients come from calldata; nested calldata (e.g. money account approve+deposit) uses a three-phase path (discovery EXACT_INPUT with fee reserve → TransactionPayController:getAmountData to patch nested data → final EXACT_OUTPUT). Wallet/from now prefers accountOverride over txParams.from. Slippage checks move to validateRelayRateDrift (USD rate ratio) with tunable feeReserveMultiplier / maxRateDriftPercent. calculateTotals uses the user’s fiatPaymentAmount when a fiat strategy quote is present.

Transaction Pay API — Optional getAmountData constructor callback and messenger action; skipProcessTransactions on QuoteRequest.

Relay quotes & submit — Post-quote gas handling reserves native gas (incl. Polygon 0x1010) with getPostQuoteGasBuffer; batch gas estimation includes the original tx for 7702 post-quote paths; prepended batch txs inherit relay fee fields. Relay submit skips EOA balance checks for post-quote, payment override, and Relay Execute.

Transaction controllergenerateEIP7702BatchTransaction sets top-level value to the sum of nested call values when non-zero.

Reviewed by Cursor Bugbot for commit 4808a41. Bugbot is set up for automated code reviews on this repo. Configure here.

@OGPoyraz OGPoyraz requested a review from a team as a code owner June 3, 2026 12:24
@OGPoyraz OGPoyraz marked this pull request as draft June 3, 2026 12:24
@OGPoyraz OGPoyraz temporarily deployed to default-branch June 3, 2026 12:24 — with GitHub Actions Inactive
@OGPoyraz OGPoyraz changed the title Ogp/fiat money account deposit fix fix: Fiat flow on MoneyAccountDeposit Jun 3, 2026
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
@OGPoyraz OGPoyraz force-pushed the ogp/fiat-money-account-deposit-fix branch from 3f77b67 to 0560a35 Compare June 3, 2026 12:31
@OGPoyraz OGPoyraz marked this pull request as ready for review June 3, 2026 13:04
@OGPoyraz OGPoyraz requested a review from a team as a code owner June 3, 2026 13:04
@OGPoyraz OGPoyraz temporarily deployed to default-branch June 3, 2026 13:04 — with GitHub Actions Inactive
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
@OGPoyraz OGPoyraz force-pushed the ogp/fiat-money-account-deposit-fix branch from b3b05dd to 8ca96e8 Compare June 3, 2026 13:25
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-submit.test.ts Outdated
Comment thread packages/transaction-pay-controller/src/utils/totals.ts
Comment thread packages/transaction-pay-controller/src/utils/totals.ts
@OGPoyraz OGPoyraz changed the title fix: Fiat flow on MoneyAccountDeposit fix: MMPay fiat payment fixes Jun 3, 2026
Comment thread packages/transaction-pay-controller/CHANGELOG.md Outdated
Comment thread packages/transaction-pay-controller/src/types.ts
Comment thread packages/transaction-pay-controller/src/utils/quotes.ts Outdated
Comment thread packages/transaction-pay-controller/src/utils/totals.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-quotes.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-quotes.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
OGPoyraz added a commit that referenced this pull request Jun 4, 2026
- Consolidate duplicate changelog entries for #8987
- Alphabetize destructured properties in updateQuotes
- Rename getPaymentAmount to getSourceAmount for clarity
- Simplify walletAddress in fiat-quotes to use transaction.txParams.from
Comment thread packages/transaction-pay-controller/src/strategy/fiat/fiat-submit.ts Outdated
OGPoyraz added a commit that referenced this pull request Jun 4, 2026
- Consolidate duplicate changelog entries for #8987
- Alphabetize destructured properties in updateQuotes
- Rename getPaymentAmount to getSourceAmount for clarity
- Simplify walletAddress in fiat-quotes to use transaction.txParams.from
@OGPoyraz OGPoyraz force-pushed the ogp/fiat-money-account-deposit-fix branch from 5ce7386 to d9d35fd Compare June 4, 2026 15:31
@OGPoyraz
Copy link
Copy Markdown
Member Author

OGPoyraz commented Jun 4, 2026

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.1-preview-a65eb72
@metamask-previews/accounts-controller@39.0.0-preview-a65eb72
@metamask-previews/address-book-controller@7.1.2-preview-a65eb72
@metamask-previews/ai-controllers@0.7.0-preview-a65eb72
@metamask-previews/analytics-controller@1.1.0-preview-a65eb72
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-a65eb72
@metamask-previews/announcement-controller@8.1.0-preview-a65eb72
@metamask-previews/app-metadata-controller@2.0.1-preview-a65eb72
@metamask-previews/approval-controller@9.0.1-preview-a65eb72
@metamask-previews/assets-controller@8.3.2-preview-a65eb72
@metamask-previews/assets-controllers@108.5.0-preview-a65eb72
@metamask-previews/authenticated-user-storage@2.0.0-preview-a65eb72
@metamask-previews/base-controller@9.1.0-preview-a65eb72
@metamask-previews/base-data-service@0.1.3-preview-a65eb72
@metamask-previews/bridge-controller@73.2.1-preview-a65eb72
@metamask-previews/bridge-status-controller@72.0.2-preview-a65eb72
@metamask-previews/build-utils@3.0.4-preview-a65eb72
@metamask-previews/chain-agnostic-permission@1.6.1-preview-a65eb72
@metamask-previews/chomp-api-service@3.1.0-preview-a65eb72
@metamask-previews/claims-controller@0.5.2-preview-a65eb72
@metamask-previews/client-controller@1.0.1-preview-a65eb72
@metamask-previews/compliance-controller@2.1.0-preview-a65eb72
@metamask-previews/composable-controller@12.0.1-preview-a65eb72
@metamask-previews/config-registry-controller@0.4.0-preview-a65eb72
@metamask-previews/connectivity-controller@0.2.0-preview-a65eb72
@metamask-previews/controller-utils@12.1.0-preview-a65eb72
@metamask-previews/core-backend@6.3.2-preview-a65eb72
@metamask-previews/delegation-controller@3.0.1-preview-a65eb72
@metamask-previews/earn-controller@12.2.0-preview-a65eb72
@metamask-previews/eip-5792-middleware@3.0.4-preview-a65eb72
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-a65eb72
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-a65eb72
@metamask-previews/ens-controller@19.1.3-preview-a65eb72
@metamask-previews/eth-block-tracker@15.0.1-preview-a65eb72
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-a65eb72
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-a65eb72
@metamask-previews/foundryup@1.0.1-preview-a65eb72
@metamask-previews/gas-fee-controller@26.2.2-preview-a65eb72
@metamask-previews/gator-permissions-controller@4.2.0-preview-a65eb72
@metamask-previews/geolocation-controller@0.1.3-preview-a65eb72
@metamask-previews/json-rpc-engine@10.5.0-preview-a65eb72
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-a65eb72
@metamask-previews/keyring-controller@26.0.0-preview-a65eb72
@metamask-previews/logging-controller@8.0.2-preview-a65eb72
@metamask-previews/message-manager@14.1.2-preview-a65eb72
@metamask-previews/messenger@1.2.0-preview-a65eb72
@metamask-previews/messenger-cli@0.2.0-preview-a65eb72
@metamask-previews/money-account-balance-service@1.0.2-preview-a65eb72
@metamask-previews/money-account-controller@0.3.2-preview-a65eb72
@metamask-previews/money-account-upgrade-controller@2.0.3-preview-a65eb72
@metamask-previews/multichain-account-service@10.0.2-preview-a65eb72
@metamask-previews/multichain-api-middleware@3.1.3-preview-a65eb72
@metamask-previews/multichain-network-controller@3.1.3-preview-a65eb72
@metamask-previews/multichain-transactions-controller@7.1.1-preview-a65eb72
@metamask-previews/name-controller@9.1.2-preview-a65eb72
@metamask-previews/network-controller@32.0.0-preview-a65eb72
@metamask-previews/network-enablement-controller@5.3.0-preview-a65eb72
@metamask-previews/notification-services-controller@24.1.2-preview-a65eb72
@metamask-previews/passkey-controller@2.0.1-preview-a65eb72
@metamask-previews/permission-controller@13.1.1-preview-a65eb72
@metamask-previews/permission-log-controller@5.1.0-preview-a65eb72
@metamask-previews/perps-controller@7.0.0-preview-a65eb72
@metamask-previews/phishing-controller@17.2.0-preview-a65eb72
@metamask-previews/polling-controller@16.0.6-preview-a65eb72
@metamask-previews/preferences-controller@23.1.0-preview-a65eb72
@metamask-previews/profile-metrics-controller@3.1.6-preview-a65eb72
@metamask-previews/profile-sync-controller@28.1.1-preview-a65eb72
@metamask-previews/ramps-controller@14.1.1-preview-a65eb72
@metamask-previews/rate-limit-controller@7.0.1-preview-a65eb72
@metamask-previews/react-data-query@0.2.1-preview-a65eb72
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-a65eb72
@metamask-previews/sample-controllers@5.0.1-preview-a65eb72
@metamask-previews/seedless-onboarding-controller@10.0.0-preview-a65eb72
@metamask-previews/selected-network-controller@26.1.3-preview-a65eb72
@metamask-previews/shield-controller@5.1.2-preview-a65eb72
@metamask-previews/signature-controller@39.2.4-preview-a65eb72
@metamask-previews/snap-account-service@0.3.0-preview-a65eb72
@metamask-previews/social-controllers@2.2.1-preview-a65eb72
@metamask-previews/storage-service@1.0.1-preview-a65eb72
@metamask-previews/subscription-controller@6.1.3-preview-a65eb72
@metamask-previews/transaction-controller@66.0.1-preview-a65eb72
@metamask-previews/transaction-pay-controller@23.1.0-preview-a65eb72
@metamask-previews/user-operation-controller@41.2.3-preview-a65eb72
@metamask-previews/wallet@2.0.0-preview-a65eb72

OGPoyraz added 18 commits June 5, 2026 14:32
Pass fiatPayment.amountFiat from quote context into calculateTotals so
the fiat flow uses the user-entered fiat amount for the total instead
of deriving it from token amounts or targetAmount.
- Consolidate duplicate changelog entries for #8987
- Alphabetize destructured properties in updateQuotes
- Rename getPaymentAmount to getSourceAmount for clarity
- Simplify walletAddress in fiat-quotes to use transaction.txParams.from
Transactions without nested calldata (e.g. Perps, Predict deposits) now
use a single EXACT_INPUT relay quote after fiat settlement instead of the
three-phase discovery + re-encoding + delegation flow.

This reduces relay calls from 3 to 1, uses cheaper EXACT_INPUT fees,
and avoids leftover dust on the source chain.

The three-phase flow is preserved for moneyAccountDeposit and other
transactions with nested calldata that requires re-encoding.
…iat submit

- Add fee-as-buffer strategy to prevent EXACT_OUTPUT cost overruns after
  fiat settlement by reserving the original relay fee from the discovery
  source amount and adding the discovery fee back to the final target.

- Simple deposits (Perps, Predict) skip the three-phase discovery flow
  and use a single EXACT_INPUT relay quote for cheaper fees and no dust.

- Split fiat-submit.ts into focused modules:
  - fiat-submit.ts: orchestration (polling, validation, routing)
  - fiat-submit-simple.ts: single EXACT_INPUT relay path
  - fiat-submit-with-calldata.ts: three-phase flow with fee buffer
  - utils.ts: shared validateRelayRateDrift, extractProviderCode

- Add configurable feeReserveMultiplier and maxRateDriftPercent via
  confirmations_pay_fiat feature flag with safe defaults (1 and 10%).
@OGPoyraz OGPoyraz force-pushed the ogp/fiat-money-account-deposit-fix branch from 124114b to 57a14f2 Compare June 5, 2026 12:36
@OGPoyraz OGPoyraz force-pushed the ogp/fiat-money-account-deposit-fix branch from 56a5321 to d4d107c Compare June 5, 2026 13:26
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4808a41. Configure here.

@amitabh94
Copy link
Copy Markdown
Contributor

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.1-preview-4808a4122
@metamask-previews/accounts-controller@39.0.0-preview-4808a4122
@metamask-previews/address-book-controller@7.1.2-preview-4808a4122
@metamask-previews/ai-controllers@0.7.0-preview-4808a4122
@metamask-previews/analytics-controller@1.1.0-preview-4808a4122
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-4808a4122
@metamask-previews/announcement-controller@8.1.0-preview-4808a4122
@metamask-previews/app-metadata-controller@2.0.1-preview-4808a4122
@metamask-previews/approval-controller@9.0.1-preview-4808a4122
@metamask-previews/assets-controller@8.3.2-preview-4808a4122
@metamask-previews/assets-controllers@108.5.0-preview-4808a4122
@metamask-previews/authenticated-user-storage@2.0.0-preview-4808a4122
@metamask-previews/base-controller@9.1.0-preview-4808a4122
@metamask-previews/base-data-service@0.1.3-preview-4808a4122
@metamask-previews/bridge-controller@73.2.1-preview-4808a4122
@metamask-previews/bridge-status-controller@72.0.2-preview-4808a4122
@metamask-previews/build-utils@3.0.4-preview-4808a4122
@metamask-previews/chain-agnostic-permission@1.6.1-preview-4808a4122
@metamask-previews/chomp-api-service@3.1.0-preview-4808a4122
@metamask-previews/claims-controller@0.5.2-preview-4808a4122
@metamask-previews/client-controller@1.0.1-preview-4808a4122
@metamask-previews/compliance-controller@2.1.0-preview-4808a4122
@metamask-previews/composable-controller@12.0.1-preview-4808a4122
@metamask-previews/config-registry-controller@0.4.0-preview-4808a4122
@metamask-previews/connectivity-controller@0.2.0-preview-4808a4122
@metamask-previews/controller-utils@12.1.0-preview-4808a4122
@metamask-previews/core-backend@6.3.2-preview-4808a4122
@metamask-previews/delegation-controller@3.0.1-preview-4808a4122
@metamask-previews/earn-controller@12.2.0-preview-4808a4122
@metamask-previews/eip-5792-middleware@3.0.4-preview-4808a4122
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-4808a4122
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-4808a4122
@metamask-previews/ens-controller@19.1.3-preview-4808a4122
@metamask-previews/eth-block-tracker@15.0.1-preview-4808a4122
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-4808a4122
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-4808a4122
@metamask-previews/foundryup@1.0.1-preview-4808a4122
@metamask-previews/gas-fee-controller@26.2.2-preview-4808a4122
@metamask-previews/gator-permissions-controller@4.2.0-preview-4808a4122
@metamask-previews/geolocation-controller@0.1.3-preview-4808a4122
@metamask-previews/json-rpc-engine@10.5.0-preview-4808a4122
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-4808a4122
@metamask-previews/keyring-controller@26.0.0-preview-4808a4122
@metamask-previews/logging-controller@8.0.2-preview-4808a4122
@metamask-previews/message-manager@14.1.2-preview-4808a4122
@metamask-previews/messenger@1.2.0-preview-4808a4122
@metamask-previews/messenger-cli@0.2.0-preview-4808a4122
@metamask-previews/money-account-balance-service@1.0.2-preview-4808a4122
@metamask-previews/money-account-controller@0.3.2-preview-4808a4122
@metamask-previews/money-account-upgrade-controller@2.0.3-preview-4808a4122
@metamask-previews/multichain-account-service@10.0.2-preview-4808a4122
@metamask-previews/multichain-api-middleware@3.1.3-preview-4808a4122
@metamask-previews/multichain-network-controller@3.1.3-preview-4808a4122
@metamask-previews/multichain-transactions-controller@7.1.1-preview-4808a4122
@metamask-previews/name-controller@9.1.2-preview-4808a4122
@metamask-previews/network-controller@32.0.0-preview-4808a4122
@metamask-previews/network-enablement-controller@5.3.0-preview-4808a4122
@metamask-previews/notification-services-controller@24.1.2-preview-4808a4122
@metamask-previews/passkey-controller@2.0.1-preview-4808a4122
@metamask-previews/permission-controller@13.1.1-preview-4808a4122
@metamask-previews/permission-log-controller@5.1.0-preview-4808a4122
@metamask-previews/perps-controller@7.0.0-preview-4808a4122
@metamask-previews/phishing-controller@17.2.0-preview-4808a4122
@metamask-previews/polling-controller@16.0.6-preview-4808a4122
@metamask-previews/preferences-controller@23.1.0-preview-4808a4122
@metamask-previews/profile-metrics-controller@3.1.6-preview-4808a4122
@metamask-previews/profile-sync-controller@28.1.1-preview-4808a4122
@metamask-previews/ramps-controller@14.1.1-preview-4808a4122
@metamask-previews/rate-limit-controller@7.0.1-preview-4808a4122
@metamask-previews/react-data-query@0.2.1-preview-4808a4122
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-4808a4122
@metamask-previews/sample-controllers@5.0.1-preview-4808a4122
@metamask-previews/seedless-onboarding-controller@10.0.0-preview-4808a4122
@metamask-previews/selected-network-controller@26.1.3-preview-4808a4122
@metamask-previews/shield-controller@5.1.2-preview-4808a4122
@metamask-previews/signature-controller@39.2.4-preview-4808a4122
@metamask-previews/snap-account-service@0.3.0-preview-4808a4122
@metamask-previews/social-controllers@2.2.1-preview-4808a4122
@metamask-previews/storage-service@1.0.1-preview-4808a4122
@metamask-previews/subscription-controller@6.1.3-preview-4808a4122
@metamask-previews/transaction-controller@66.0.1-preview-4808a4122
@metamask-previews/transaction-pay-controller@23.1.0-preview-4808a4122
@metamask-previews/user-operation-controller@41.2.3-preview-4808a4122
@metamask-previews/wallet@2.0.0-preview-4808a4122

amitabh94 added a commit to MetaMask/metamask-mobile that referenced this pull request Jun 5, 2026
Replaces the temporary yarn patch with the preview package from
MetaMask/core#8987 for local testing. Not intended to merge.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
return {
data,
to: from,
...(totalValue > BigInt(0) ? { value: toHex(totalValue) } : {}),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't how EIP-7702 works. The to is the from so you'd just be passing value to yourself, plus each call is empowered to pass value as it uses a solidity call that includes its own data, to, and value.

What issue were you trying to fix?


### Fixed

- Fix fiat `moneyAccountDeposit` failing after on-ramp settlement by adding `getAmountData` callback for calldata re-encoding and correcting wallet address, quote amount, and slippage validation ([#8987](https://github.com/MetaMask/core/pull/8987))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not the same as in changed, could we combine into one?

const transactionData = state.transactionData[transactionId];
const amountFiat = transactionData?.fiatPayment?.amountFiat;
const walletAddress = transaction.txParams.from as Hex;
const walletAddress = (transactionData?.accountOverride ??
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not needed right as quotes.ts does this in the request?

const skipBalanceCheck =
Boolean(quote.request.isPostQuote) ||
Boolean(quote.request.paymentOverride) ||
Boolean(quote.original.metamask.isExecute);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still want to validate the balance before doing the execute flow, as it's final validation before the user spends their funds.

: ({
data: transaction.txParams.data as Hex | undefined,
from: transaction.txParams.from,
maxFeePerGas: normalizedParams[0]?.maxFeePerGas,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, we use the first params in addTransaction later, but if we prepended, that will now be undefined so it will just figure it out on the fly during addTransaction even though Relay may have provided some good fees.

* @param options.transaction - The transaction metadata.
* @returns An object containing the relay transaction hash if available.
*/
export async function submitWithCalldataReEncoding({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, could just be submitWithTransactionData for clarity?

...baseRequest,
isMaxAmount: false,
isPostQuote: true,
sourceBalanceRaw: sourceAmountRaw,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, I don't think the relay strategy uses sourceBalanceRaw anywhere, but I see this is pre-existing.

}

// Fee in USD = what the relay consumed beyond the target value
const feeUsd = sourceUsd.minus(targetUsd);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we re-calculating this if this is fees.provider.usd on our normalized quote from Relay?


const adjusted = targetMinRaw.plus(discoveryFeeInTargetRaw);

log('calculateAdjustedTarget', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, Adjusted target?

}

// Convert fee from USD to raw target token units
const usdPerTargetRaw = targetUsd.dividedBy(targetMinRaw);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be enough for our purposes, but just a warning we're using the estimated target USD but the minimum target raw, so that may skew the target USD rate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants